/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.cadi.levelsManager;

import com.cadi.aux.Coin;
import com.cadi.aux.CounterIntermediate;
import com.cadi.menu.MainMenu;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JLayeredPane;

/**
 *
 * @author ApoZuniga
 */
public class LevelsCountDifficult extends CounterIntermediate {
    private JLabel background;
    public LevelsCountDifficult() {
        super();
        voice = java.applet.Applet.newAudioClip(getClass().getResource("/resources/cuentas2.wav"));
        voice.play();
        toMenu.setVisible(true);
        currentLevel = 1;
        
        listenerGood = new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent ae) {
                totalActionPerformed(ae, 1);
                changeLevel();
            }
        };
        
        listenerBad = new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent ae) {
                totalActionPerformed(ae, 0);
            }
        };
        
        objectOne = new Coin(20, "large");
        objectOne.setBounds(70, 200, 150, 100);
        container.add(objectOne, JLayeredPane.PALETTE_LAYER);
        objectTwo = new Coin(50, "large");
        objectTwo.setBounds(320, 200, 150, 100);
        container.add(objectTwo, JLayeredPane.PALETTE_LAYER);
        objectThree = new Coin(10, "small");
        objectThree.setBounds(570, 200, 75, 75);
        container.add(objectThree, JLayeredPane.PALETTE_LAYER);
        objectFour = new Coin(1, "small");
        objectFour.setBounds(715, 200, 75, 75);
        container.add(objectFour, JLayeredPane.PALETTE_LAYER);
        objectFive = new Coin(20, "large");
        objectFive.setBounds(855, 200, 150, 100);
        container.add(objectFive, JLayeredPane.PALETTE_LAYER);
        
        optionTotalOne = new JButton(new ImageIcon(getClass().getResource("/resources/107.png")));
        optionTotalOne.setBounds(300, 400, 140, 70);
        optionTotalOne.addActionListener(listenerBad);
        container.add(optionTotalOne, JLayeredPane.PALETTE_LAYER);
        optionTotalTwo = new JButton(new ImageIcon(getClass().getResource("/resources/101.png")));
        optionTotalTwo.setBounds(600, 400, 140, 70);
        optionTotalTwo.addActionListener(listenerGood);
        container.add(optionTotalTwo, JLayeredPane.PALETTE_LAYER);
        optionTotalThree = new JButton(new ImageIcon(getClass().getResource("/resources/100.png")));
        optionTotalThree.setBounds(900, 400, 140, 70);
        optionTotalThree.addActionListener(listenerBad);
        container.add(optionTotalThree, JLayeredPane.PALETTE_LAYER);
        background = new JLabel(new ImageIcon(getClass().getResource("/resources/fondo5.png")));
        background.setBounds(0, 0, 1280,800);
        container.add(background, JLayeredPane.PALETTE_LAYER);
        window.setVisible(true);
    }
    
    private void setLevelTwo() {
        objectOne.changeIcon(50);
        objectOne.setBounds(90, 200, 150, 91);
        objectTwo.changeIcon(50);
        objectTwo.setBounds(320, 200, 150, 90);
        objectThree.changeIcon(5);
        objectThree.setBounds(530, 200, 75, 75);
        objectFour.changeIcon(10); //10
        objectFour.setBounds(695, 200, 75, 75);
        objectFive.setIcon(new ImageIcon(getClass().getResource("/resources/2pesos-small.png")));
        objectFive.setBounds(870, 200, 75, 75);
        optionTotalOne.setIcon(new ImageIcon(getClass().getResource("/resources/115.png")));
        optionTotalOne.setBounds(300, 400, 140, 70);
        optionTotalTwo.setIcon(new ImageIcon(getClass().getResource("/resources/111.png")));
        optionTotalTwo.setBounds(600, 400, 140, 70);
        optionTotalThree.setIcon(new ImageIcon(getClass().getResource("/resources/117.png")));
        optionTotalThree.setBounds(900, 400, 140, 70);
        
        optionTotalTwo.removeActionListener(listenerGood);
        optionTotalTwo.addActionListener(listenerBad);
        optionTotalThree.removeActionListener(listenerBad);
        optionTotalThree.addActionListener(listenerGood);
        window.repaint();
        voice.play();
    }
    
    private void setLevelThree() {
        objectOne.changeIcon(100);
        objectOne.setBounds(80, 200, 150, 95);
        objectTwo.changeIcon(20);
        objectTwo.setBounds(360, 200, 150, 100);
        objectThree.changeIcon(10);
        objectThree.setBounds(620, 200, 75, 75);
        objectFour.changeIcon(2);
        objectFour.setBounds(780, 200, 75, 75);
        objectFive.setIcon(new ImageIcon(getClass().getResource("/resources/1peso-small.png")));
        objectFive.setBounds(930, 200, 75, 75);
        optionTotalOne.setIcon(new ImageIcon(getClass().getResource("/resources/132.png")));
        optionTotalOne.setBounds(300, 400, 140, 70);
        optionTotalTwo.setIcon(new ImageIcon(getClass().getResource("/resources/133.png")));
        optionTotalTwo.setBounds(600, 400, 140, 70);
        optionTotalThree.setIcon(new ImageIcon(getClass().getResource("/resources/131.png")));
        optionTotalThree.setBounds(900, 400, 140, 70);
        
        optionTotalTwo.removeActionListener(listenerBad);
        optionTotalTwo.addActionListener(listenerGood);
        optionTotalThree.removeActionListener(listenerGood);
        optionTotalThree.addActionListener(listenerBad);
        window.repaint();
        voice.play();
    }
    
    private void setLevelFour() {
        objectOne.changeIcon(200);
        objectOne.setBounds(150, 200, 150, 93);
        objectTwo.changeIcon(100);
        objectTwo.setBounds(450, 200, 150, 95);
        objectThree.setIcon(new ImageIcon(getClass().getResource("/resources/billete200_big.jpg")));
        objectThree.setBounds(750, 200, 150, 93);
        objectFour.setIcon(new ImageIcon(getClass().getResource("/resources/billete50_big.jpg")));
        objectFour.setBounds(350, 350, 150, 91);
        objectFive.changeIcon(20);
        objectFive.setBounds(650, 350, 150, 100);
        optionTotalOne.setIcon(new ImageIcon(getClass().getResource("/resources/570.png")));
        optionTotalOne.setBounds(300, 500, 140, 70);
        optionTotalTwo.setIcon(new ImageIcon(getClass().getResource("/resources/550.png")));
        optionTotalTwo.setBounds(600, 500, 140, 70);
        optionTotalThree.setIcon(new ImageIcon(getClass().getResource("/resources/560.png")));
        optionTotalThree.setBounds(900, 500, 140, 70);
        
        optionTotalOne.removeActionListener(listenerBad);
        optionTotalOne.addActionListener(listenerGood);
        optionTotalTwo.removeActionListener(listenerGood);
        optionTotalTwo.addActionListener(listenerBad);
        window.repaint();
        voice.play();
    }
    
    private void setLevelFive() {
        objectOne.changeIcon(500);
        objectOne.setBounds(150, 200, 150, 100);
        objectTwo.changeIcon(100);
        objectTwo.setBounds(470, 200, 150, 95);
        objectThree.setIcon(new ImageIcon(getClass().getResource("/resources/billete200_big.jpg")));
        objectThree.setBounds(770, 200, 200, 93);
        objectFour.setIcon(new ImageIcon(getClass().getResource("/resources/billete50_big.jpg")));
        objectFour.setBounds(350, 350, 180, 100);
        objectFive.changeIcon(100);
        objectFive.setBounds(650, 350, 150, 95);
        optionTotalOne.setIcon(new ImageIcon(getClass().getResource("/resources/900.png")));
        optionTotalOne.setBounds(300, 500, 140, 70);
        optionTotalTwo.setIcon(new ImageIcon(getClass().getResource("/resources/850.png")));
        optionTotalTwo.setBounds(600, 500, 140, 70);
        optionTotalThree.setIcon(new ImageIcon(getClass().getResource("/resources/950.png")));
        optionTotalThree.setBounds(900, 500, 140, 70);
        
        optionTotalOne.removeActionListener(listenerGood);
        optionTotalOne.addActionListener(listenerBad);
        optionTotalThree.removeActionListener(listenerBad);
        optionTotalThree.addActionListener(listenerGood);
        window.repaint();
        voice.play();
    }
    
    private void changeLevel() {
        switch(currentLevel){
            case 1:
                setLevelTwo();
                currentLevel++;
                break;
            case 2:
                setLevelThree();
                currentLevel++;
                break;
            case 3:
                setLevelFour();
                currentLevel++;
                break;
            case 4:
                setLevelFive();
                currentLevel++;
                break;
            case 5:
                MainMenu main = new MainMenu();
                window.setVisible(false);
                break;
        }
    }
}
